//
//  DDChargeMoneyStyleCell.m
//  DingDongZP
//
//  Created by 杨政涛 on 2016/12/31.
//  Copyright © 2016年 51ledian.com. All rights reserved.
//

#import "DDChargeMoneyStyleCell.h"

@implementation DDChargeMoneyStyleCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self){
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.backgroundColor = COLOR_BACKGROUND_GRAY;
        
        UIImageView *BgImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"paykuang"]];
        [self.contentView addSubview:BgImageView];
        
        
        self.logoImage = [[UIImageView alloc]init];
        self.logoImage.layer.masksToBounds = YES;
        [BgImageView addSubview:self.logoImage];
        
        self.chargeMoneyLabel = [[UILabel alloc]init];
        self.chargeMoneyLabel.textColor = COLOR_FONT_BLACK;
        self.chargeMoneyLabel.font = [UIFont systemFontOfSize:15];
        [BgImageView addSubview:self.chargeMoneyLabel];
        
        self.daoZanLabel = [[DDCustomLabel alloc]init];
        self.daoZanLabel.textColor = COLOR_FONT_LIGHT_GRAY;
        self.daoZanLabel.font = [UIFont systemFontOfSize:13];
        [BgImageView addSubview:self.daoZanLabel];
        
        
        self.selectedImage = [[UIImageView alloc]init];
        self.selectedImage.layer.masksToBounds = YES;
        self.selectedImage.image = [UIImage imageNamed:@"gou2"];
        [BgImageView addSubview:self.selectedImage];
        
        WEAKSELF
        [BgImageView mas_makeConstraints:^(MASConstraintMaker *make){
            
            make.top.left.right.mas_equalTo(weakSelf);
            make.bottom.mas_equalTo(weakSelf).offset(-9);
        }];
        
        [self.logoImage mas_makeConstraints:^(MASConstraintMaker *make){
            
            make.left.mas_equalTo(BgImageView).offset(20);
            make.centerY.mas_equalTo(BgImageView);
            make.width.height.equalTo(@(23));
        }];
        
        [self.chargeMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make){
            
            make.left.mas_equalTo(self.logoImage.mas_right).offset(10);
            make.centerY.mas_equalTo(BgImageView);
        }];
        
        [self.daoZanLabel mas_makeConstraints:^(MASConstraintMaker *make){
            
            make.left.mas_equalTo(self.chargeMoneyLabel.mas_right).offset(10);
            make.centerY.mas_equalTo(BgImageView);
        }];
        
        self.selectedImage.layer.cornerRadius = 23/2;
        [self.selectedImage mas_makeConstraints:^(MASConstraintMaker *make){
            
            make.right.mas_equalTo(BgImageView).offset(-20);
            make.centerY.mas_equalTo(BgImageView);
            make.width.height.equalTo(@(23));
        }];
    }
    return self;
}

- (void)setDataModel:(DDRechargeTypeModel *)dataModel
{
    
    self.logoImage.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",dataModel.leftImage]];
    self.chargeMoneyLabel.text = [NSString stringWithFormat:@"充值%@元",!dataModel.real_money?@"0":dataModel.real_money];
    self.daoZanLabel.text = [NSString stringWithFormat:@"到账%@元",!dataModel.money?@"0":dataModel.money];
    
    if (dataModel.money) {
        
    [self.daoZanLabel setAttributeLabelWithtextColorPairs:@[@{dataModel.money:COLOR_FONT_LIGHT_GREEN}]];
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
